from selenium.webdriver.common.by import By
from common.Utils import BlogDriver
from tests.BlogLogin import BlogLoginDriver
from tests.BlogList import BlogListDriver
from tests.BlogDetail import BlogDetailDriver
from tests.BlogEdit import BlogEditDriver

if __name__ == '__main__':
    # 未登录状态下的简墨列表、简墨博客详情、简墨博客发布
    BlogListDriver.ListByNotLogin()
    BlogDetailDriver.DetailByNotLogin()
    BlogEditDriver.EditByNotLogin()
    # 异常登录
    BlogLoginDriver.LoginFailAllTest()
    BlogLoginDriver.LoginFailUserTest()
    BlogLoginDriver.LoginFailPassTest()
    # 成功登录
    BlogLoginDriver.LoginSucTest()
    # 检查简墨列表
    BlogListDriver.ListByLogin()
    # 进入简墨博客详情页并检查元素
    BlogLoginDriver.driver.find_element(By.CSS_SELECTOR, "body > div.container > div.right > div:nth-child(2) > a").click()
    BlogDetailDriver.DetailByLogin()
    # 进入简墨博客发布页发布
    BlogDriver.driver.back()
    BlogLoginDriver.driver.find_element(By.CSS_SELECTOR, "body > div.nav > a:nth-child(5)").click()
    BlogEditDriver.EditByLogin()

    BlogDriver.driverQuit()